<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>东单办公系统-学院新增</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="stylesheet" href="media/layui/css/layui.css" media="all">
<script type="text/javascript" src="media/js/jquery.min.js"></script>
</head>
<body>

	<div class="layui-container" style="margin-top: 50px;margin-left: 15%;">
		<form class="layui-form" action="studentadd.do" method="post" id="form1" onsubmit="return false">
			<div class="layui-form-item">
				<label class="layui-form-label">学号</label>
				<div class="layui-input-inline">
					<input type="text" name="u_no" lay-verify="name" autocomplete="off"
						placeholder="请输入学号" class="layui-input">
				</div>
				<label class="layui-form-label">姓名</label>
				<div class="layui-input-inline">
				<input type="text" name="name" lay-verify="name" autocomplete="off"
					   placeholder="请输入姓名" class="layui-input">
			</div>
				
			</div>
			<div class="layui-form-item">
			<label class="layui-form-label">出生日期</label>
				<div class="layui-input-inline">
					<input type="date" name="birthday" id="date" autocomplete="off"
						class="layui-input" placeholder="请选择生日">
				</div>
				<label class="layui-form-label">性别</label>
				<div class="layui-input-inline">
					<input type="radio" name="sex" value="男" title="男" checked>
					<input type="radio" name="sex" value="女" title="女" >
				</div>
			</div>
			<div class="layui-form-item">
				
				<label class="layui-form-label">身份证号</label>
				<div class="layui-input-inline">
					<input type="number" name="cardno" lay-verify="name"
						autocomplete="off" placeholder="请输入身份证号" class="layui-input">
				</div>
				<label class="layui-form-label">班级</label>
				<div class="layui-input-inline">
					<select name="gno" lay-verify="required" id="d1">
						<option value=""></option>
					</select>
				</div>
			</div>
			
			<div class="layui-form-item">
				<label class="layui-form-label">学校</label>
				<div class="layui-input-inline">
					<input type="text" name="schoolname" lay-verify="name"
						autocomplete="off" placeholder="请输入学校名" class="layui-input">
				</div>
				<label class="layui-form-label">学历</label>
				<div class="layui-input-inline">
					<input type="text" name="education" lay-verify="name"
						autocomplete="off" placeholder="请输入学历" class="layui-input">
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label">手机号</label>
				<div class="layui-input-inline">
					<input type="number" name="phone" lay-verify="name"
						autocomplete="off" placeholder="请输入手机号" class="layui-input">
				</div>
				<label class="layui-form-label">邮箱</label>
				<div class="layui-input-inline">
					<input type="text" name="email" lay-verify="name"
						autocomplete="off" placeholder="请输入邮箱" class="layui-input">
				</div>
				
			</div>

			<div class="layui-form-item">
			<label class="layui-form-label">QQ号</label>
				<div class="layui-input-inline">
					<input type="number" name="qq" lay-verify="name"
						autocomplete="off" placeholder="请输入qq号" class="layui-input">
				</div>
				<label class="layui-form-label">介绍人</label>
				<div class="layui-input-inline">
					<input type="text" name="introno" lay-verify="name"
						autocomplete="off" placeholder="请输入介绍人" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item" >
				<div class="layui-input-block" style="left: 35%;margin-top: 20px;">
						<input class="layui-btn" type="submit" id="submit1" value="确认新增">
				</div>
			</div>
		</form>
	</div>


	<script src="media/layui/layui.js"></script>
	<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
	<script>
		layui.use(['form', 'layedit', 'laydate'], function(){
			var form = layui.form
					,layer = layui.layer
					,layedit = layui.layedit;

			layui.$.ajax({
				url: "student/selectGrade.do",
				type: 'get',
				dataType: 'json',
				success: function (data) {
					console.log(data)
					console.log(data.data)
					/* index 是要遍历的下标
                    *  item 是对应下标的对象 */
					$.each(data.data, function (index, item) {
						$('#d1').append(new Option(item.name, item.id));// 下拉菜单里添加元素
					});
					layui.form.render("select");//重新渲染 固定写法
				},
			});
		})


		$("#submit1").click(function () {
			$.ajax({
				type:'post',
				url:'student/insertStudent.do',
				data:$("#form1").serialize(),
				dataType:'json',
				success:function (data) {
					if (data.code == 1) {
						alert(data.msg)
						window.location.href = "gradelist.html"
					} else {
						alert(data.msg)
					}
				}
			})
			return false;
		})


	</script>
</body>
</html>